var sw = function (window, swjsfile) {
    var _applicationCache = require('./applicationCache');

    swjsfile = swjsfile || '/app/sw.js';
    window.addEventListener('DOMContentLoaded', function() {
        if (navigator && navigator.serviceWorker) {
            var html = document.getElementsByTagName("html")[0]
            var version = html.getAttribute("version");

            var Notification = window.Notification || window.mozNotification || window.webkitNotification;
            navigator.serviceWorker.register(swjsfile).then(function (swReg) {
                //alert('成功')
                /*Notification.requestPermission(function (status) {

                })*/
            }).catch(function (error) {
                console.log(error)
                // alert('失败')
            });
        } else {
            _applicationCache(window);
        }
    })
};
module.exports = sw;